//
//  LPCSVProgressHUD.m
//  SQShopping
//
//  Created by 李沛池 on 2017/12/27.
//  Copyright © 2017年 李沛池. All rights reserved.
//

#import "LPCSVProgressHUD.h"
#import <SVProgressHUD.h>
#import <AVFoundation/AVFoundation.h>
#import "LPCDefine.h"

@implementation LPCSVProgressHUD

//初始化
+ (void)load
{
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleLight];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeGradient];
    [SVProgressHUD setBackgroundColor:RGBACOLOR(0, 0, 0, 0.8)];
    [SVProgressHUD setForegroundColor:[UIColor whiteColor]];
    [SVProgressHUD setMinimumDismissTimeInterval:1.3f];
}

//纯信息
void LPCHUDShowMessage(NSString *text)
{
    if (![NSThread isMainThread]) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD showInfoWithStatus:text];
        });
    }else{
        [SVProgressHUD showInfoWithStatus:text];
    }
}

//成功
void LPCHUDShowSuccess(NSString *text)
{
    if (![NSThread isMainThread]) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD showSuccessWithStatus:text];
        });
    }else{
        [SVProgressHUD showSuccessWithStatus:text];
    }
}

//失败
void LPCHUDShowError(NSString *text)
{
    if (![NSThread isMainThread]) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD showErrorWithStatus:text];
            [SVProgressHUD showProgress:0.5 status:@"上传"];
        });
    }else{
        [SVProgressHUD showErrorWithStatus:text];
    }
}

//持续转动
void LPCHUDShowMask(NSString *text)
{
    if (![NSThread isMainThread]) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD showWithStatus:text];
        });
    }else{
        [SVProgressHUD showWithStatus:text];
    }
}

//进度条
void LPCHUDShowProgress(CGFloat progress)
{
    if (![NSThread isMainThread]) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD showProgress:progress];
        });
    }else{
        [SVProgressHUD showProgress:progress];
    }
}

//消失
void LPCHUDDismiss(void)
{
    if (![NSThread isMainThread]) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD dismiss];
        });
    }else{
        [SVProgressHUD dismiss];
    }
}

@end
